﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data;

namespace MMS
{
    public abstract class DBHelper
    {
        /// <summary>
        /// 执行INSERT、DELETE、UPDATE语句并返回执行后受影响的行数
        /// </summary>
        /// <param name="sql">要执行的INSERT、DELETE、UPDATE语句</param>
        /// <returns>执行后受影响的行数</returns>
        public abstract int ExecuteNonQuery(string sql);

        /// <summary>
        /// 执行SELECT语句并返回首行首列值
        /// </summary>
        /// <param name="sql">要执行的SELECT语句</param>
        /// <returns>首行首列值</returns>
        public abstract object ExecuteScalar(string sql);

        /// <summary>
        /// 执行SELECT语句并返回查询结果读取器
        /// </summary>
        /// <param name="sql">要执行的SELECT语句</param>
        /// <returns>查询结果读取器</returns>
        public abstract DbDataReader ExecuteReader(string sql);

        /// <summary>
        /// 执行SELECT语句并返回查询表结果
        /// </summary>
        /// <param name="sql">要执行的SELECT语句</param>
        /// <returns>查询表结果</returns>
        public abstract DataTable ExecuteDadaList(string sql);

        public abstract void Open();
        public abstract void Close();
    }
}
